import request from '@/utils/axios'
// minio预签名
export function presignedUrl(data: {name: string, type: number}): Promise<any> {
  return request({
    url: `/upload?name=${data.name}&type=${data.type}`,
    method: 'get'
  })
}

export function getPhotoList(data:any): Promise<any> {
  return request({
    url: `/upload/list?pageNo=${data.pageNo}&pageSize=${data.pageSize}&type=${data.type}`,
    method: 'get'
  })
}
// oss预签名
export function getOssSigned(): Promise<any> {
  return request({
    url: '/upload/oss-signed',
    method: 'get'
  })
}

// 上传到oss
export function uploadToOss(data:any, url:string): Promise<any> {
  return request({
    url: url,
    method: 'post',
    data
  })
}

//上传url到服务器
export function uploadFile(data: {url: string, type: number}): Promise<any> {
  return request({
    url: '/upload/uploadFile',
    method: 'post',
    data
  })
}

// 删除图片
export function deleteImageByUrl(data: {url: string}): Promise<any> {
  return request({
    url: '/upload/deleteImageByUrl',
    method: 'post',
    data
  })
}

// 批量删除图片
export function multiDelete(data: {urls: string}): Promise<any> {
  return request({
    url: '/upload/multiDelete',
    method: 'post',
    data
  })
}
